<!-- templates/group_management.html -->
{% extends "admin/layout.html" %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between mb-4">
        <h4><i class="fas fa-comments me-2"></i>群组管理</h4>
        <a href="{{ url_for('wxwork.create_group') }}" class="btn btn-primary">
            <i class="fas fa-plus me-2"></i>创建新群组
        </a>
    </div>

    <div class="row">
        {% for group in groups %}
        <div class="col-md-4 mb-4">
            <div class="card h-100">
                <div class="card-body">
                    <h5 class="card-title">{{ group.name }}</h5>
                    <p class="text-muted">群主：{{ group.owner.name }}</p>
                    <div class="mt-3">
                        <span class="badge bg-primary">成员：{{ group.members.count() }}</span>
                        {% if group.assigned_tags %}
                        <span class="badge bg-info ms-2">标签：{{ group.assigned_tags }}</span>
                        {% endif %}
                    </div>
                </div>
                <div class="card-footer d-flex justify-content-between">
                    <a href="{{ url_for('wxwork.group_detail', group_id=group.id) }}"
                       class="btn btn-sm btn-outline-primary">
                        <i class="fas fa-eye me-1"></i>查看
                    </a>
                    <form action="{{ url_for('wxwork.dismiss_group', group_id=group.id) }}" method="post"
                          onsubmit="return confirm('确定要解散该群组吗？')">
                        <input name="csrf_token" type="hidden" value="{{ csrf_token() }}">
                        <button type="submit" class="btn btn-sm btn-outline-danger">
                            <i class="fas fa-trash me-1"></i>解散
                        </button>
                    </form>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
</div>
{% endblock %}